﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ParallelArrays;
using FPA = Microsoft.ParallelArrays.FloatParallelArray;
using BPA = Microsoft.ParallelArrays.BoolParallelArray;
using IPA = Microsoft.ParallelArrays.IntParallelArray;
using PA = Microsoft.ParallelArrays.ParallelArrays;

namespace CoreCalc.SheetDefinedFunctions.Accellerator
{
    class UnaryAccNode : AccExpr
    {
        AccExpr param;

        public enum Type { SUM,SQRT }

        Type type;

        public UnaryAccNode(Type type, AccExpr param)
        {
            this.param = param;
            this.type = type;
        }

        protected override Microsoft.ParallelArrays.FloatParallelArray GenerateFPA(AccInputInfo info, int CallID)
        {
            switch(this.type) {
                case Type.SUM:
                    return Microsoft.ParallelArrays.ParallelArrays.Sum(param.GenerateFPAWithCache(info, CallID));
                case Type.SQRT:
                    return PA.Sqrt(param.GenerateFPAWithCache(info, CallID));
                   
            
            }
            throw new NotImplementedException("Unkown operation");
            
        }
    }
}
